package ru.evreke.service.socket

import ServerMessage
import io.ktor.server.websocket.*
import org.koin.core.context.GlobalContext
import ru.evreke.service.State

class WebsocketSessionService {
    private val state by GlobalContext.get().inject<State>()

    fun getPlayerWsSession(playerId: String): DefaultWebSocketServerSession? {
        return state.getWebsocketSessions()[playerId]
    }

    fun addPlayerAndWsSession(playerId: String, wsSession: DefaultWebSocketServerSession) {
        state.addWebsocketSession(playerId, wsSession)
    }

    suspend fun removePlayerWsSession(playerId: String) {
        state.removeWebsocketSession(playerId)
    }

    fun sendMessageToWsSession(message: ServerMessage) {
        TODO()
    }
}